export const mixins = {
	methods: {
		_m_getUserMsg() {
			this.$api.userMsg().then(
				(res) => {				
					this.$u.vuex('vuex_myMsg', res)
					uni.setStorageSync('myMsg',JSON.stringify(res))
				},
				(err) => {
					console.log(err);
				}
			);
		},
		_m_gettitleClass(pageSize) {
			this.$api.gettitleClass({pageSize:pageSize}).then(
				(res) => {
					this.titleClass = res
				},
				(err) => {
					console.log(err);
				}
			)
		},
		_m_getDetailCID(cid) {
			this.$api.gettitleClass().then(
				res => {			
					let newicd = cid.split(',')
					for (let i = 0; i < newicd.length; i++) {
						if (isNaN(newicd[i]) == false) {
							res.forEach(item => {
								if (item.cid == +newicd[i]) {
									this.cid += '#'+item.title + ','
								}
							})

						} else {
							this.cid += newicd[i]
						}

					}

				},
				err => {
					console.log(err);
				}
			)
		},
		_m_getMyCollection(id){
			this.$api.getCollection(id).then(
			res=>{
				this.usertitle=res
				
			} 
			)
		},
		_m_getPulicMsg(uid) {
			this.$api.getOtherUserMsg({
				uid: uid
			}).then(
				res => {
						return res.username
				},
				err => {
					console.log(err);
				}
			)
		},
		_m_getUserComments(aid) {
			this.$api.getUserComment({
				aid: aid
			}).then(
				res => {
						this.titleClass = res
				},
				err => {
					this.$Message.error(err.msg)
				}
			)
		},
		_m_gettitleMsg() {
			this.$api.gettitleMsg({}).then(
				res => {
					this.title = res
				},
				err => {
					console.log(err);
				}
			)
		},
		_m_collection(id){
			this.$api.collection(id).then(
			res=>{
				if(res!==0){
					this.$refs.uToast.show({
						duration:3000,
						title:'收藏成功',
						type:'success'
					})	
				}
					
			})
		},
		
	},


}
export const mixinsPost = {
		methods: {
			closeAvatarDialog(data) {
				this.headerPhotoURL = data;
				this.dialogVisible = false;
			},
			xixixi(value) {
				this.setNew.imgUrl = value
			}
		}
	}

export const mix_com = {
		computed: {
			usertitles() {
				if(this.usertitle){
					return this.usertitle.filter(item => {
					if (this.select == 'title') {
						return item.title.includes(this.keyword) == true
					} else if (this.select == 'body') {
						return item.body.includes(this.keyword) == true
					} else if (this.select == 'time') {
						return item.createTime.includes(this.keyword) == true
					}

				})
				}else{
					return 0
				}
				
			}
		}
	}
